package cn.dengta.webapp.trade.form;

import java.math.BigDecimal;

import cn.dengta.common.validator.Check;
import cn.dengta.common.validator.Range;
import cn.dengta.context.model.AppContext;
import cn.dengta.context.model.TradeFormI18nKey;
import cn.dengta.webapp.base.form.BaseForm;
import cn.dengta.webapp.trade.entity.CashLog;
import cn.dengta.webapp.trade.model.Currency;
import cn.dengta.webapp.trade.model.PayPlatform;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import me.codeplayer.util.Assert;
import me.codeplayer.util.X;

/**
 * 提现账号
 *
 * @author yuqidi
 * @since 2022-03-24
 */
@Setter
@Getter
@Accessors(chain = true)
public class CashForm extends BaseForm<CashLog> {

	@Check(TradeFormI18nKey.CASH_ACCOUNT_FORM_PLATFORM)
	public PayPlatform platform;

	@Check(value = TradeFormI18nKey.CASH_FORM_CASH, required = false)
	@Range(min = 0, canEqMin = false)
	public BigDecimal cash;

	@Check(TradeFormI18nKey.CASH_FORM_INTEGRAL_AMOUNT)
	@Range(min = 1)
	public BigDecimal integralAmount;

	/** 提现币种 */
	@Check(TradeFormI18nKey.CASH_ACCOUNT_FORM_CURRENCY)
	public Currency currency;

	/** 固定提现金额配置 ID*/
	public Long cashConfigId;
	/** 快速提现积分记录id */
	public transient Long fastIntegralId;

	@Override
	public void preHandle() {
	}

	public void setPlatform(Integer platform) {
		this.platform = PayPlatform.of(platform);
	}

	public void setCurrency(String currency) {
		this.currency = Currency.of(currency);
	}

}
